import request from '@/utils/request.js';

// 栏目列表查询
export const columnListService = () => {
  return request.get('/columns/columnList');
};

// 获取父级栏目
export const getParentColumnsService = () => {
  return request.get('/columns/getParentColumns');
};

// 获取父级子栏目
export const getChildrencolumnsService = (pid) => {
  return request.get(`/columns/getChildrenColumns?pid=${pid}`);
};

// 获取所有子栏目
export const AllChildrencolumnsService = () => {
  return request.get('/columns/selectAllChildrenColumns');
};

// 栏目添加服务
export const addColumnService = (data) => {
  return request.post('/columns/addColumn', data);
};

// 获取栏目详情服务
export const getColumnDetailService = (cid) => {
  return request.get(`/columns/columnDetail?cid=${cid}`);
};

// 更新栏目服务
export const updateColumnService = (data) => {
  return request.put('/columns/updateColumn', data);
};

// 文件上传服务
export const uploadFileService = (file) => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: '/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};
// 删除栏目服务
export const deleteColumnService = (columnId) => {
  return request.delete(`/columns/deleteColumn?columnId=${columnId}`);
};